<?php 
/****
若	水
博	客: http://www.wangzhaobo.top
****/

namespace Admin\Controller;
use Think\Controller;
class LoginController extends Controller{
	public function index(){
		$this->display();
	}
	public function login(){
		$user = M('User');
		$where['name'] = I('name');
		$where['password'] = I('password');
		$code = I('code');
		$res = $user->where($where)->find();
		$verify = new \Think\Verify();    
		$str = $verify->check($code, 1);
		if(!$str){
			//$this->error('验证码错误','',2);
		}
		if($res){
			session('name',$where['password']);
			$this->success('登录成功','/Admin/index/index',2);
		}else{
			$this->error('账号或者密码错误','',2);
		}
	}
	public function loginOut(){
		session('name',null); // 删除names
		$this->success('退出成功','index',2);
	}
	public function getVerify(){
		$config =    array(
		    'imageW'    =>100,    	// 验证码字体大小
		    'mageH'     =>34,     	// 验证码位数
		    'useNoise'  =>false, 	// 关闭验证码杂点
		    'useCurve'	=>false,	//是否使用混淆曲线 默认为true
		    'length'	=>4,
		    'fontSize'	=>15,
		    'bg'		=> array(243, 251, 254),
		    'codeSet'	=>'012345689'
		);
		$Verify =     new \Think\Verify($config);
		//$Verify->useZh = true;// 设置验证码字符
		//$Verify->zhSet = '们以我到他会作时要动国产的一是工就年阶义发成部民可出能方进在了不和有大这'; 
		$Verify->entry(1);
	}
}

?>